package string;

/**
 * @author justnow
 * Created on 2020-10-07
 * Description
 *
 * 反转字符串，原地修改
 *
 *
 */
public class Leetcode344 {

    public static void reverseString(char[] s) {
        if (s == null || s.length <= 0) {
            return;
        }
        int length = s.length;
        int left = 0, right = length - 1;
        while (left < right) {
            char temp = s[left];
            s[left] = s[right];
            s[right] = temp;
            left++;
            right--;
        }
    }

    public static void main(String[] args) {
        String test = "hello";
        char[] array = test.toCharArray();
        reverseString(array);
    }
}
